package code.snippet

import scala.xml.NodeSeq
import net.liftweb.http.{S, RoundTripInfo}
import net.liftweb.http.js.JE.JsRaw
import net.liftweb.http.js.JsCmds.Script

class RoundtripExam {
  def render = {
    (for {
      sess <- S.session
    } yield {
      Script(
        JsRaw("var ServerFuncs = " + sess.buildRoundtrip(List[RoundTripInfo]("double" -> doDouble _)).toJsCmd).cmd)
    }) openOr NodeSeq.Empty
  }

  private def doDouble(s: String): String = {
    //serverActor.foreach(actor => actor ! s"Client call double function with $s") //bug do nothing with this line.
    s + " " + s
  }
}
